//
//  LNHCyclePagerViewCell.m
//  LNH
//
//  Created by cruise on 2018/2/6.
//  Copyright © 2018年 twentylx. All rights reserved.
//

#import "LNHCyclePagerViewCell.h"

@implementation LNHCyclePagerViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        
        self.backgroundColor = [UIColor whiteColor];
        
        [self.contentView addSubview:self.wmPlayer];
        [self.contentView addSubview:self.imageView];
        
        [self.wmPlayer mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView);
        }];
        
        [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView);
        }];
        
        [RACObserve(self, isVideo) subscribeNext:^(id  _Nullable x) {
            self.wmPlayer.hidden = ![x boolValue];
            self.imageView.hidden = [x boolValue];
        }];
    }
    return self;
}

-(UIImageView *) imageView {
    if (!_imageView) {
        _imageView = [UIImageView new];
        _imageView.contentMode = UIViewContentModeScaleAspectFit;
    }
    return _imageView;
}

-(WMPlayer *) wmPlayer {
    if (!_wmPlayer) {
        _wmPlayer = [[WMPlayer alloc] init];
        _wmPlayer.closeBtn.hidden = YES;
        _wmPlayer.fullScreenBtn.hidden = YES;
    }
    return _wmPlayer;
}

@end
